package com.runner.unlocks;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.ImageButton;
import com.badlogic.gdx.scenes.scene2d.ui.Label;
import com.badlogic.gdx.scenes.scene2d.ui.Label.LabelStyle;
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener;
import com.runner.observer.Event;
import com.runner.observer.Subject;
import com.runner.utility.Constants;
import com.runner.utility.Locator;

public class RingerUnlock implements Constants{

	private ImageButton button;
	private Subject subject;
	private Label name;
	
	public RingerUnlock(Stage stage, LabelStyle style, Subject subject){
		this.subject=subject;
		createButton(stage,style);
	}
	
	public void createButton(Stage stage, LabelStyle style){
		Image i=new Image(Locator.getAssets().get(RINGER_PICTURE, Texture.class));
		button=new ImageButton(i.getDrawable());
		button.addListener(new ClickListener() {
			@Override
			public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
				subject.notify(Event.EVENT_RINGER_SELECTED);
				return false;
			}
		});
		button.setPosition(ACTUAL_VIRTUAL_WIDTH * RINGER_X, ACTUAL_VIRTUAL_HEIGHT * (RINGER_Y+ HEIGHT_ADJUST));
		button.getImage().setScale(1);
		button.setScale(1);
		
		name=new Label("Ringer",style);
		name.setPosition(ACTUAL_VIRTUAL_WIDTH * (RINGER_X +0.04f), ACTUAL_VIRTUAL_HEIGHT * (RINGER_Y + 0.168f+ HEIGHT_ADJUST));
		stage.addActor(name);
		stage.addActor(button);
	}
	
	public PLAYER_TYPE getType(){
		return PLAYER_TYPE.RINGER;
	}
	
}
